package com.huawei.appmarket.service.appdetail.view.card;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.jsonkit.api.JsonBean;
import com.huawei.appmarket.framework.widget.ArrowImageView;
import com.huawei.appmarket.framework.widget.FoldingTextView;
import com.huawei.appmarket.framework.widget.FoldingTextView.b;
import com.huawei.appmarket.framework.widget.FoldingTextView.c;
import com.huawei.appmarket.service.store.awk.bean.DetailNoticeCardBean;
import com.huawei.appmarket.service.store.awk.bean.DetailNoticeCardBean.NoticeItemBean;
import java.util.List;
import o.azb;
import o.cii;
import o.ckt;
import o.dgh;
import o.drl;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;

public class DetailNoticeCard extends drl implements OnClickListener, c {
    protected ArrowImageView ʻ;
    protected FoldingTextView ʼ;
    protected TextView ʽ;
    private LayoutInflater ˋॱ;
    protected DetailNoticeCardBean ॱˊ;
    protected ViewGroup ॱॱ;

    public DetailNoticeCard() {
        this.ॱ = 317;
    }

    public View ˊ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.ˋॱ = layoutInflater;
        this.ˊ = layoutInflater.inflate(h.ˏˏ, null);
        azb.ˏ(this.ˊ, j.ˎꓸ);
        azb.ॱ(this.ˊ, j.ˌˏ);
        this.ʽ = (TextView) this.ˊ.findViewById(j.ʼﾞ);
        this.ʻ = (ArrowImageView) this.ˊ.findViewById(j.ˎꜟ);
        this.ʼ = (FoldingTextView) this.ˊ.findViewById(j.ˌᐝ);
        this.ʼ.setOnContentChangedListener(this);
        this.ʼ.setMaxLine(3);
        this.ʼ.setResize(true);
        this.ॱॱ = (ViewGroup) this.ˊ.findViewById(j.ˍˎ);
        return this.ˊ;
    }

    public boolean ˊ(List<JsonBean> list) {
        if (list == null || list.size() <= 0) {
            return false;
        }
        JsonBean jsonBean = (JsonBean) list.get(0);
        if (!(jsonBean instanceof DetailNoticeCardBean)) {
            return false;
        }
        this.ॱˊ = (DetailNoticeCardBean) jsonBean;
        ᐝ();
        ʼ();
        return true;
    }

    protected void ᐝ() {
        if (this.ʽ != null && !TextUtils.isEmpty(this.ॱˊ.v_())) {
            this.ʽ.setText(this.ॱˊ.v_());
        }
    }

    protected void ʼ() {
        int i = 2;
        int i2 = 0;
        if (this.ॱˊ != null) {
            List ॱ = this.ॱˊ.ॱ();
            if (ॱ != null && ॱ.size() > 0) {
                Object ˋ = ((NoticeItemBean) ॱ.get(0)).ˋ();
                if (TextUtils.isEmpty(ˋ)) {
                    this.ʼ.setVisibility(8);
                    if (ॱ.size() <= 2) {
                        i = ॱ.size();
                    }
                    this.ॱॱ.setVisibility(0);
                    while (i2 < i) {
                        this.ॱॱ.addView(ˊ((NoticeItemBean) ॱ.get(i2)));
                        i2++;
                    }
                    return;
                }
                this.ʼ.setVisibility(0);
                this.ʼ.setContent(ˋ);
                ʽ();
            }
        }
    }

    public void onClick(View view) {
        ʻ();
        this.ʼ.ˎ();
    }

    protected void ʽ() {
        this.ʼ.setOnClickListener(this);
        this.ʻ.setOnClickListener(this);
    }

    public void ˎ(boolean z, b bVar, String str, String str2) {
        if (z && this.ʻ != null) {
            if (this.ʻ.getVisibility() == 8) {
                this.ʻ.setVisibility(0);
            }
            if (bVar == b.All) {
                this.ʻ.setArrowUp(true);
            } else {
                this.ʻ.setArrowUp(false);
            }
        }
    }

    private View ˊ(final NoticeItemBean noticeItemBean) {
        if (this.ˋॱ == null || noticeItemBean == null) {
            return null;
        }
        View inflate = this.ˋॱ.inflate(h.ˎˏ, null);
        azb.ˏ(inflate);
        RelativeLayout relativeLayout = (RelativeLayout) inflate.findViewById(j.ٴˋ);
        TextView textView = (TextView) inflate.findViewById(j.ՙᐝ);
        TextView textView2 = (TextView) inflate.findViewById(j.ՙˊ);
        final Context context = this.ˊ.getContext();
        CharSequence ॱ = noticeItemBean.ॱ();
        CharSequence ˏ = noticeItemBean.ˏ();
        if (TextUtils.isEmpty(ॱ)) {
            textView.setVisibility(8);
            textView2.setMaxLines(2);
            relativeLayout.setMinimumHeight(0);
            int dimensionPixelSize = context.getResources().getDimensionPixelSize(d.ᐨ);
            relativeLayout.setPadding(0, dimensionPixelSize, 0, dimensionPixelSize);
        }
        textView.setText(ॱ);
        textView2.setText(ˏ);
        inflate.setOnClickListener(new ckt(new OnClickListener(this) {
            final /* synthetic */ DetailNoticeCard ˏ;

            public void onClick(View view) {
                BaseCardBean baseCardBean = new BaseCardBean();
                baseCardBean.ˊˋ(this.ˏ.ॱˊ.u_());
                baseCardBean.ॱ(noticeItemBean.ˊ());
                cii.ˊ().ˊ(context, baseCardBean);
                this.ˏ.ˎ(noticeItemBean.ˊ());
            }
        }));
        return inflate;
    }

    private void ˎ(String str) {
        dgh.ॱ("091202", "url", str);
    }

    private void ʻ() {
        dgh.ॱ("091201", "action", "click");
    }
}
